const { Menu, BrowserWindow } = require("electron")

const template = [
  {
    label: '主菜单1',
    submenu: [
      {label: '菜单1.1'},
      {label: '菜单1.2'},
      {label: '菜单1.3'},
      {label: '菜单1.4'}
    ]
  }, 
  {
    label: '主菜单2',
    submenu: [
      {
        label: '菜单2.1',
        accelerator: 'ctrl+n', // 快捷键
        click: () => { // 点击事件
          let win = new BrowserWindow({
            width: 300,
            height: 200
          })
          win.loadFile('index2.html')
          win.on("close", () => {
            win = null
          })
        }
      }
    ]
  },
  {
    label: '主菜单3'
  }
]

const mymenu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(mymenu)
